package com.xunji.xunji.module.account.ui.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xunji.xunji.R;
import com.xunji.xunji.module.account.bean.MyTrace;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Paul on 2017/2/28.
 */

public class MyTraceAdapter extends BaseAdapter {
    private List<MyTrace> list = new ArrayList();

    public MyTraceAdapter(List<MyTrace> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder = null;
        if (convertView==null){
            holder = new Holder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_my_track,null);
            holder.textView = (TextView) convertView.findViewById(R.id.tv_title);

            convertView.setTag(holder);

        }else {
            holder = (Holder) convertView.getTag();
        }

        holder.textView.setText(list.get(position).getTitle());

        return convertView;
    }

    class Holder{
        TextView textView;
    }

}
